package jwr;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class ListenerSample extends JFrame{
	public ListenerSample() {
		setSize(400, 300);
		setVisible(true);
		setDefaultCloseOperation(this.EXIT_ON_CLOSE);
		
		getContentPane();
		setLayout(new FlowLayout());
		
		MyListener ml = new MyListener();
		
		JButton jb = new JButton("확인");
		jb.addActionListener(ml);
		add(jb);
	}

	public static void main(String[] args) {
		new ListenerSample();
	}

}

class MyListener implements ActionListener{

	@Override
	public void actionPerformed(ActionEvent e) {
		JButton jb = (JButton)e.getSource();
		
		if(jb.getText().equals("확인"))
			jb.setText("Check");
		else
			jb.setText("확인");
	}
	
}
